package com.qire.manhua.model.entity;

import com.qire.manhua.model.enumeration.AdActionType;

/** 平台内推送广告 */
public class AppInternalAdvert {

    public final AdActionType actionType;
    public final String advertImage;
    public final long   advertDuration;
    public final int    comicId;
    public final String advertTitle;
    public final String advertUrl;

    public AppInternalAdvert(AdActionType actionType, String advertImage, long advertDuration, int comicId, String advertTitle, String advertUrl) {
        this.actionType     = actionType;
        this.advertImage    = advertImage;
        this.advertDuration = advertDuration;
        this.comicId        = comicId;
        this.advertTitle    = advertTitle;
        this.advertUrl      = advertUrl;
    }

    public void doAction() {
        switch (actionType) {
            case ToWebPage :
                actionType.action.doAction(advertUrl, advertTitle);
                break;
            case ToComicDetail :
            case ToComicReader : {
                if (comicId <= 1)
                    return;
                actionType.action.doAction(new ComicBookEntity(comicId, advertTitle));
                break;
            }
        }
    }
}
